<!doctype html>
<html>

<head>
	<title></title>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
	<link rel="stylesheet" href="../res/css/weui.css" />
	<link rel="stylesheet" href="../res/css/weuix.css" />
	<link rel="stylesheet" href="../res/css/mp_common.css" />
	<link rel="stylesheet" href="../res/css/common.css" />
	<script src="../res/js/zepto.min.js"></script>
	<script src="../res/js/zepto.weui.js"></script>
	<script src="../res/js/mp_common.js?v=1"></script>
	<script src="../res/js/qrcode.min.js"></script>
	<script src="../res/js/common.js"></script>
	<script src="../res/js/JsBarcode.all.min.js" type="text/javascript"></script>

	<!-- 核销码 -->
	<!-- <script src="../res/js/verification.js"></script>
	<link rel="stylesheet" href="../res/css/verification.css" /> -->
</head>
<style>
	.weui-cells {
		font-size: 15px;
	}

	.weui-cell {
		margin-bottom: 0px;
	}

	.weui-btn:after {
		content: none;
	}

	.fixed-top {
		position: fixed;
		top: 0;
		width: 100%;
		z-index: 100;
	}

	.show_drug {
		display: flex;
		height: 60px;
		margin-top: 10px;
	}

	.drug_img {
		width: 60px;
		height: 60px;
		float: left;
		border-radius: 10px;
	}

	.show_drug>div {
		padding-left: 10px;
		color: #8a8a8a;
		float: left;
		height: 60px;
		line-height: 30px;
		position: relative;
	}

	.drug_price {
		position: absolute;
		top: 12px;
		right: 20px;
		color: #FA6464;
	}

	.titleDiv {
		margin-top: 40px;
		background-color: #fff;
		display: flex;
		justify-content: space-between;
	}

	.titleDiv div {
		padding: 15px 20px;
	}

	#p_status {
		font-size: 20px;
		color: #353535;
		font-weight: bold;
		font-family: PingFang-SC-Medium;
	}

	#goSeeOrder {
		color: #4187F7;
		line-height: 30px;
	}

	#callShop {
		background-color: #fff;
		display: flex;
		justify-content: space-between;
		padding: 10px 0;
		flex-wrap: wrap;
	}

	#p_pat_name {
		font-size: 15px;
		color: #353535;
		font-weight: bold;
	}

	#p_pat_address {
		font-size: 15px;
		color: #353535;
		font-weight: bold;
	}

	#takePhoto {
		display: flex;
		flex-direction: column;
		margin-right: 20px;
		align-items: center;
	}

	.drug_price {
		position: absolute;
		top: 5px;
		right: 10px;
		color: #000;
		font-size: 19px;
	}

	#goGetTheMedicine{
		background-color: #fff;
		padding-left: 18px;
		display: none;
	}
	.inner-box{
		/* text-align: center; */
		/* line-height: 60px; */
		/* background-color: #eee; */
		color: #FA6464;
	}

	.drug_num{
		display: flex;
		flex-grow: 1;
		flex-direction: column;
		justify-content: space-evenly;
	}
	.drug_num>div{
		line-height: 16px;
	}
</style>

<body ontouchstart>
	<div class="fixed-top" style="padding:7px 2px; background-color: #ffffff;">
		<div class="weui-flex__item">
			<div class="placeholder">
				<span class="icon icon-109" style=" margin-left: 8px;" onclick="ToPage()"></span>
				<span style=" padding-left: 33%;">订单信息</span>
			</div>
		</div>
	</div>
	<div class="titleDiv">
		<div id="p_status">待收货</div>
		<div id="goSeeOrder">查看原始处方 ></div>
	</div>
	<div id="div_dd_info">
		<div id="goGetTheMedicine">
			<div class="inner-box">
				请到院内窗口缴费及取药
			</div>		
		</div>
		
		<div id="callShop">
			<div style="display: flex;">
				<img src="../res/images/link_people_icon.png" alt=""style="width: 35px;height: 35px;padding: 20px 0px;padding-left: 20px;">

				<div style="display: flex; align-items: center; flex-direction: column;">
					<div id="p_pat_address" style="padding: 5px 5px;color: #868686;font-weight: 500;"></div>
					<div id="p_pat_name" style="padding: 5px 5px;">收货人</div>
				</div>
			</div>
			<a id="takePhoto" href="#">
				<img src="../res/images/link-phone.png" alt="" style="width: 40px;height: 40px;">
				<div style="width: 100%;text-align: center;color: #4187F7;font-size: 15px;">联系商家</div>
			</a>
		</div>
		<div class="weui-cells" id="div_kd_info">
			<div class="weui-cell">
				<div class="weui-cell__bd" id="div_kd_info_msg">
					<p style="font-size: 12px;"></p>
					<p style="font-size: 12px;">承运快递为，运单号：<span style="color:Blue;">[复制]</span></p>
					<p style="font-size: 12px;">发货时间：</p>
				</div>
			</div>
		</div>

		<!-- 核销码 -->
		<!-- <div id="verificationView">
			<div id="verificationCode">
				核销码: <span id="codeContent">xxxxxxx</span>
			</div>
		</div> -->

		<div class="weui-cells">
			<div class="weui-cell">
				<div class="weui-cell__bd" id="div_dd_dtl">
				</div>
			</div>
		</div>
		<!-- <div class="weui-cells">
			<div class="weui-cell">
				<div class="weui-cell__bd">
					<p style="font-size: 13px;">总金额</p>
				</div>
				<div class="weui-cell__ft" style="font-size: 13px;" id="div_sum_price">￥19.9</div>
			</div>
			<div class="weui-cell" id="div_kd_yf">
				<div class="weui-cell__bd">
					<p style="font-size: 13px;">运费</p>
				</div>
				<div class="weui-cell__ft" style="font-size: 13px;" id="div_yf_price">￥0</div>
			</div>
		</div> -->
		<div class="weui-cells">
			<div class="weui-cell">
				<div class="weui-cell__bd" id="div_dd_ls_info">
					<p style="font-size: 12px;padding: 5px;border-bottom: 1px solid #F2F2F2;">订单信息</p>
					<p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
						订单编号：<span style="margin-right: 10px;">1000880</span></p>
					<p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
						下单时间：<span style="margin-right: 10px;">1000880</span></p>
				</div>
			</div>
		</div>
		<div style="color: #C9C9C9;text-align: center;padding: 60px 0 !important">如有疑问，可联系客服</div>
		<div class="weui-cells" style="margin:0px !important;margin-bottom: 10px;position: fixed;bottom: 0px;width: 100%;overflow: hidden;">
			<div class="weui-cell" style="margin:0px !important;">
				<div class="weui-cell__bd">
					<p style="font-size: 13px;"></p>
				</div>
				<div class="weui-cell__ft" style="font-size: 13px; margin-left:10px;" id="div_act_btn2">
					<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_primary"
						style="width:100px; color:#1189ff;    border: 1px solid;" onclick="wxDoPay();"
					>确认支付
					</a>
				</div>
			</div>
		</div>
	</div>

</body>

</html>
<script type="text/javascript">
	var prescription_id = "",
		wxcode = '',
		money = 0,
		order_sn = '';
	var indent_state = "0";
	var orderDetail = {};
	var loc_y, loc_x;

	let inside = getQst('inside')
	if(!inside || inside === 'false'){
		inside = false
	}else{
		inside = true
	}
	switchStateKey(inside)
	let stateKey = inside ? 'payState' : 'indent_state'

	$(function () {
		// 注释掉下面这条会导致无法支付 非测试环境不要注释
		getCode();

		strOrgId = getQst("orgid");
		strOpenId = getQst("openid");
		user_id = getQst("user_id");
		order_id = getQst("prescription_id").trim();
		// 获取订单数据，拿到处方号再获取处方信息
		if(isHis && inside){
			hisOrderDetails()
			$("#goGetTheMedicine").show()
		}else{
			orderInfo()
		}
		// -------------------
	});
	//获取订单数据
	function orderInfo() {
		let params = {
			"order_num": order_id
		}
		newAjaxPost("/h5/thirdParty/orderDetail", params, orderInfoOk);
	}
	// his订单详情
	function hisOrderDetails() {
		let params = {
			id: order_id,
		}
		newAjaxPost("/h5/lianjiang/his/getPrescriptionInfoById", params, orderInfoOk)
	}

	function orderInfoOk(rstData) {
		if(inside){
			var snKey = 'outTradeNo',
				timeKey = 'createTime',
				idKey = 'id'
		}else{
			var snKey = 'order_sn',
				timeKey = 'create_time',
				idKey = 'rp_id'
		}

		var data = rstData.data
		if (rstData.code == 1) {
			if (!isHis) {
				$("#takePhoto").attr("href", `tel:${rstData.data.store_phone}`)
			}
			prescription_id = data[idKey]
			money = data.indent_total;
			order_sn = data.order_sn;
			orderDetail = rstData.data;
			loc_y = data.lng || data.loc_y;
			loc_x = data.lat || data.loc_x;
			// if (rstData.list[0].pay_status == "0") {
			// 	$("#p_status").html("未支付");
			// }else{
			// 	$("#p_status").html(rstData.list[0].indent_state);
			// }
			if (data[stateKey] == STwaitPay) {
				//10:未付款(待付款)
				$("#p_status").html("待付款");
			} else if (data[stateKey] == STwaitTake) {
				//35:待自提
				$("#p_status").html("待自提");
			} else if (data[stateKey] == STcancel) {
				console.log(data[stateKey],STcancel);
				//订单状态：0:已取消  
				$("#p_status").html("已取消");
			} else if (data[stateKey] == STwaitSend) {
				//20:待发货
				$("#p_status").html("待发货");
			} else if (data[stateKey] == STsended) {
				//30:已发货(待收货)
				$("#p_status").html("待收货");
			} else if (data[stateKey] == STfinished) {
				//40:已收货(已完成)
				$("#p_status").html("已完成");
			}
			// $("#p_user_mark").html("手机号："+rstData.list[0].pat_photo);
			$("#div_kd_info").hide();

			if (data.payWay == 'offline') {
				$("#div_act_btn2").hide()
			}

			var str_dd_ls_info = "";
			str_dd_ls_info += `<p style="font-size: 12px;padding: 5px;border-bottom: 1px solid #F2F2F2;">订单信息</p>
            <p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
                        订单编号：<span style="margin-right: 10px;">${rstData.data[snKey] }</span></p>
            <p style="font-size: 12px;padding: 5px;display: flex;justify-content: space-between;">
                        下单时间：<span style="margin-right: 10px;">${rstData.data[timeKey]}</span></p>`
			// if (rstData.data.pay_status == "1") {
			//     str_dd_ls_info = str_dd_ls_info + "<p style=\"font-size: 12px;\">支付状态：已支付</p>";
			// } else {
			//     str_dd_ls_info = str_dd_ls_info + "<p style=\"font-size: 12px;\">支付状态：未支付</p>";
			// }
			// str_dd_ls_info = str_dd_ls_info + "<p style=\"font-size: 12px;\">取药方式：" + (rstData.data.take_type == "1" ?
			//     "快递派送" : "上门自取") + "</p>";
			$("#div_dd_ls_info").html(str_dd_ls_info);
			$("#div_sum_price").html("￥" + data.indent_total);


			if (data.take_type == "2") {
				$("#p_pat_name").html("取货人：" + rstData.data.pat_name);
				if (isSpace(rstData.data.pat_photo)) {
					$("#p_pat_address").html("取货手机号：未设置");
				} else {
					$("#p_pat_address").html("取货手机号：" + rstData.data.pat_photo);
				}
				$("#div_kd_yf").hide();
				if (!isSpace(data.logistics_name)) {
					$("#div_kd_tx").hide();
					$("#div_kd_info").show();
					var kd_info_html = "";
					kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">药店名称： " + data.store_name + "</p>";
					kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">药店地址： " + data.store_dz + "</p>";
					$("#div_kd_info_msg").html(kd_info_html);
				}
			} else if (data.take_type == "1") {
				$("#takePhoto").hide()
				$("#p_pat_name").html(rstData.data.pat_name + " " + rstData.data.pat_photo);
				if (isSpace(rstData.data.address_detl)) {
					$("#p_pat_address").html("收货地址：未设置");
				} else {
					$("#p_pat_address").html(rstData.data.address_name + " " + rstData.data.address_detl);
				}
				$("#txt_logistics_name").val(data.logistics_name);
				$("#txt_logistics_no").val(data.logistics_no);
				$("#txt_logistics_cost").val(data.logistics_cost);
				$("#div_yf_price").html("￥" + data.logistics_cost);

				if (!isSpace(data.logistics_name)) {
					$("#div_kd_tx").hide();
					$("#div_kd_info").show();
					var kd_info_html = "";
					kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">您的订单已由" + data.logistics_name + "承运</p>";
					kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">运单号：" + data.logistics_no + "</p>";
					kd_info_html = kd_info_html + "<p style=\"font-size: 12px;\">发货时间：" + data.send_time + "</p>";
					$("#div_kd_info_msg").html(kd_info_html);
				}
			}


			indent_state = data.indent_state;
			var pay_status = data.pay_status;
			if (pay_status == "1" || indent_state == "已完成") {
				$("#div_act_btn1").html(
					"<a href=\"javascript:;\" class=\"weui-btn weui-btn_mini weui-btn_primary\" style=\"width:100px;\">删除订单</a>"
				);
				$("#div_act_btn2").html(
					"<a href=\"javascript:;\" class=\"weui-btn weui-btn_mini weui-btn_primary\" style=\"width:100px;margin-left:10px;background-color:gray;\" disable>已支付</a>"
				);
			}
			var paramJson = {
				"prescriptionNo": prescription_id
			};

			if (inside) {
				// 院内订单详情所需信息都在这一个接口 不需要后面的
				let ele = 
				`<div style="padding: 10px 10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;">
					<span>${data.hospitalName}</span>
					<span style="margin-right:20px;color: #4187F7;" onclick="actToPage('user_dtl_map.htm?loc_x=${data.lat || data.loc_x}&loc_y=${data.lng || data.loc_y}')">查看地图></span>
				</div>`
				// `<div style="padding: 10px 10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;">
				// 	<span style="margin-right:20px;">${orderDetail.hospitalName}</span>
				// 	<span style="margin-right:20px;color: #4187F7;" onclick="actToPage('user_dtl_map.htm?loc_x=${loc_x}&loc_y=${loc_y}')">查看地图</span>
				// </div>`
				data.prescriptionInfoVOList.forEach(item => {
					var temp = item.drugSpecifications
						? `<div>${item.drugSpecifications}</div>`
						: `<div>${item.detailsConsumption} ${item.detailsConsumptionUnit}</div>`
					ele += `
						<div class="show_drug">
							<img src="${isSpace(item.drugImg) ? "../res/images/medisen1.jpg" : item.drugImg}" class="drug_img">
							<div class="drug_num">
								<div class="drug_name" style="display:flex;justify-content: space-between;">
									<div>${item.drugName}</div>
									<div class="drug_price" style="position: unset;">￥${item.drugPrice}</div>
								</div>

								<div style="font-size:12px;display:flex;justify-content: space-between;">
									${temp}
									<div style="margin-right:10px">x${item.detailsNum}</div>
								</div>
							</div>
						</div>
					`
					// ${item.detailsConsumption} ${item.drugPackagingUnit}
				})

				ele += `
					<div style="padding:6px 0px; text-align:right; color: #4187F7;" onclick="goPage('inquiry_go_med.htm?id=' + ${data.id})">
						用药详情 >
					</div>
				`

				// font-weight:bold
				ele += `
					<div style="padding-top: 8px; padding-bottom: 6px; font-size:14px; border-top:1px solid #F2F2F2;">
						<div style="display:flex; justify-content:space-between;">
							<span style=";">商品总金额</span>
							<span>￥${data.prescriptionPrice}</span>
						</div>
						<div style="display:flex; justify-content:space-between;">
							<span style="">医保统筹/公医结账</span>
							<span>￥${Number(data.hisMiWholePrice).toFixed(2)}</span>
						</div>
					</div>
					<div style=" text-align:right; padding-top:6px; border-top:1px solid #F2F2F2;">
						应付总金额: ￥${data.price}
					</div>
				`
				
				$("#div_dd_dtl").html(ele)

				$("#p_pat_name").html(orderDetail.patientPhone)
				$("#p_pat_address").html(orderDetail.patientName.trim() || "未设置").css('color', '#000')
				$("#div_act_btn2").hide()

				$("#takePhoto").prop('href', 'tel:' + data.hospitalPhoneNumber)

				//跳转到查看原始处方页面
				$("#goSeeOrder").click(() => {
					actToPage('inquiry_go_order.htm?order_id=' + orderDetail.outTradeNo + '&id=' + orderDetail.id + '&is_order=1');
				})

				// 保存订单 提交到院内

			}else{
				// 院外订单流程不变
				newAjaxPost("/h5/myInterrogation/getPrescriptioninfo", paramJson, getDDData);
			}
		} else {
			$("#p_status").html("无该订单信息");
			$("#div_dd_info").hide();
		}
	}
	//获取数据
	function getDDData(rstData) {
		var str_dd_dtl_html = "";
		if (rstData.code == 1) {

			//跳转到查看原始处方页面
			$("#goSeeOrder").click(() => {
				actToPage('inquiry_go_order.htm?order_id=' + rstData.data.prescriptionNo + '&id=' + rstData.data
					.id + '&is_order=1');
			})

			console.log(rstData.data);
			str_dd_dtl_html +=
				'<div style="padding: 10px 10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;">';
			str_dd_dtl_html += '<span style="margin-right:20px;">' + orderDetail.group_name + '</span>';
			str_dd_dtl_html +=
				`<span style="margin-right:20px;color: #4187F7;" onclick="actToPage('user_dtl_map.htm?loc_x=${loc_x}&loc_y=${loc_y}')">查看地图</span>`;
			str_dd_dtl_html += '</div>';
			//西药列表
			if (rstData.data.westernMedicineResqList != null) {
				for (var i = 0; i < rstData.data.westernMedicineResqList.length; i++) {
					str_dd_dtl_html += '<div class="show_drug">';
					str_dd_dtl_html += '<img src="' + (isSpace(rstData.data.westernMedicineResqList[i].drugImg) ?
							"../res/images/medisen1.jpg" : rstData.data.westernMedicineResqList[i].drugImg) +
						'" class="drug_img">';
					str_dd_dtl_html += '<div class="drug_num">';
					str_dd_dtl_html += '<div class="drug_name">' + rstData.data.westernMedicineResqList[i].drugName + '</div>';
					str_dd_dtl_html +='<div style="font-size:12px;display:flex;justify-content: space-between;">';
					str_dd_dtl_html += '<span>' + rstData.data.westernMedicineResqList[i].detailsNum + rstData.data
						.westernMedicineResqList[i].drugPackagingUnit + '</span>';
					str_dd_dtl_html += '<div style="margin-right:10px">x' + rstData.data.westernMedicineResqList[i]
						.detailsConsumption + '</div>';
					str_dd_dtl_html += '</div>';
					str_dd_dtl_html += '<div class="drug_price">￥' + rstData.data.westernMedicineResqList[i]
						.drugPrice + '</div>';
					str_dd_dtl_html += '</div>';
					str_dd_dtl_html += '</div>';
				}
			}
			//中药列表 
			else {
				for (var i = 0; i < rstData.data.chineseMedicineResqList.length; i++) {
					str_dd_dtl_html += '<div class="show_drug">';
					str_dd_dtl_html += '<img src="' + (isSpace(rstData.data.chineseMedicineResqList[i].drugImg) ?
							"../res/images/medisen1.jpg" : rstData.data.chineseMedicineResqList[i].drugImg) +
						'" class="drug_img">';
					str_dd_dtl_html += '<div class="drug_num">';
					str_dd_dtl_html += '<div class="drug_name">' + rstData.data.chineseMedicineResqList[i]
						.drugName + '</div>';
					str_dd_dtl_html +=
						'<div style="font-size:12px;display:flex;justify-content: space-between;">';
					str_dd_dtl_html += '<span>' + rstData.data.chineseMedicineResqList[i].detailsConsumption +
						rstData.data.chineseMedicineResqList[i].detailsConsumptionUnit + '</span>';
					str_dd_dtl_html += '<div style="margin-right:10px">x' + rstData.data.chineseMedicineResqList[i]
						.detailsConsumption + '</div>';
					str_dd_dtl_html += '</div>';
					str_dd_dtl_html += '<div class="drug_price">￥' + rstData.data.chineseMedicineResqList[i]
						.drugPrice + '</div>';
					str_dd_dtl_html += '</div>';
					str_dd_dtl_html += '</div>';

				}
			}
			str_dd_dtl_html += '<div style="padding:10px;border-bottom: 1px solid #F2F2F2; text-align:right">';
			str_dd_dtl_html +=
				`<span style="color: #4187F7;" onclick="actToPage('inquiry_go_med.htm?id=' + ${rstData.data.id})">用药详情></span>`;
			str_dd_dtl_html += '</div>';
			str_dd_dtl_html +=
				`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>商品总金额</div><div>￥${orderDetail.indent_total}</div></div>`
			str_dd_dtl_html +=
				`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>配送费</div><div>￥${orderDetail.logistics_cost}</div></div>`
			// if (isHis && inside) {
				// str_dd_dtl_html +=
				// 	`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>代煎费</div><div>￥0</div></div>`
				// str_dd_dtl_html +=
				// 	`<div style="padding:10px;border-bottom: 1px solid #F2F2F2;display:flex;justify-content: space-between;"><div>医保统筹/公医结账</div><div>￥0</div></div>`
			// }
			str_dd_dtl_html += '<div style="padding:10px;display:flex;justify-content:right;">';
			str_dd_dtl_html +=
				`<span style="font-size: 15px;font-weight: bold;">应付总金额: ￥${orderDetail.indent_total}</span>`;
			str_dd_dtl_html += '</div>';
			// console.log(rstData.data.indent_total);

			$("#div_dd_dtl").html(str_dd_dtl_html);
			newAjaxPost("/h5/userInfo/userInfo", {}, doOk);

			function doOk(res) {
				var userInfo = res.data;
				if (userInfo.userImg == undefined || userInfo.userImg == null) {
					$("#img_user_head").attr("src", '../res/images/head_icon.png');
				} else {
					$("#img_user_head").attr("src", userInfo.userImg);
				}
				$("#p_user_mark").html("手机号：" + userInfo.mobile);
				$("#p_user_name").html("用户：" + (isSpace(userInfo.userNickname) ? "未设置" : userInfo.userNickname));
			}
			// if (rstData.list[0].pay_status == "0") {
			// 	$("#p_status").html("未支付");
			// }else{
			// 	$("#p_status").html(rstData.list[0].indent_state);
			// }
			// $("#p_user_mark").html("手机号："+rstData.list[0].pat_photo);
			$("#div_kd_info").hide();
		}
	}

	function jsonToStr(jsonObj) {
		return JSON.stringify(jsonObj);
	}

	function wxDoPay() {
		if (typeof WeixinJSBridge == "undefined") {
			showJSZ("此场景无法调起支付！");
			if (document.addEventListener) {
				document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
			} else if (document.attachEvent) {
				document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
				document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
			}
		} else {
			onBridgeReady();
		}
	}

	function onBridgeReady() {
		var paramJson = {
			"code": "1",
			"h5openid": wxcode,
			"money": money,
			"orderSn": order_sn
		}
		newAjaxPost("/h5/prescriptionOrder/initiatePayment", paramJson, wxDoPayOk);
	}

	function wxDoPayOk(jsonInfo) {
		if (jsonInfo.code == '1') {
			WeixinJSBridge.invoke(
				'getBrandWCPayRequest', {
					"appId": jsonInfo.data.appId, //公众号名称，由商户传入       
					"timeStamp": jsonInfo.data.timeStamp, //时间戳，自1970年以来的秒数       
					"nonceStr": jsonInfo.data.nonceStr, //随机串       
					"package": jsonInfo.data.packageWx, //"prepay_id=" + 
					"signType": jsonInfo.data.signType, //微信签名方式:       
					"paySign": jsonInfo.data.paySign //微信签名   
				},
				function (res) {
					if (res.err_msg == "get_brand_wcpay_request:ok") {


						wxDoPaySaveOk(true);
					} else
						showJSZ("用户取消支付");
				}
			);
		} else
			showJSZ(jsonInfo.msg);
	}

	function wxDoPaySave() { //修改订单状态接口--后台调用
		var pJson = {
			"order_num": order_sn,
			"type": 1
		};
		newAjaxPost("/h5/thirdParty/saveOrder", pJson, wxDoPaySaveOk);
	}

	function wxDoPaySaveOk(jsonInfo) {
		// if (jsonInfo.code == '1') {
		// $("#div_act_btn1").html("");
		// $("#div_act_btn2").html("");
		$('#div_act_btn1 a').css("pointer-events", "none");
		$('#div_act_btn1 a').css("background-color", "gray");
		$('#div_act_btn1 a').html("已支付")
		$('#div_act_btn2 a').css("pointer-events", "none");
		$('#div_act_btn2 a').css("background-color", "gray");
		showJSZ("支付成功！三秒后回到订单列表");
		setTimeout(function () {
			//2020.04.08----------
			if (!isSpace(user_id)) {
				actToPage('user_list.htm?user_id=' + user_id);
			} else {
				actToPage('user_list.htm?openid=' + strOpenId);
			}
		}, 2000);
		// }else
		//     showJSZ("保存支付结果失败");
	}

	function ToPage() {
		history.go(-2)
	}

	// 强制关注公众号，获取openid
	function getCode() {
		// if (getUrlParam("code")) {
		//     return false;
		// }
		var code = getUrlParam('code') // 截取路径中的code，如果没有就去微信授权，如果已经获取到了就直接传code给后台获取openId
		var local = window.location.href;
		var APPID = getAPPID();
		if (code == null || code === '') {
			window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + APPID +
				'&redirect_uri=' + encodeURIComponent(local) +
				'&response_type=code&scope=snsapi_base&state=#wechat_redirect'
		} else {
			getOpenId(code) //把code传给后台获取用户信息
		}
	}
	//把code传给后台,得到openid
	function getOpenId(code) {
		// wxcode = code
		var paramJson = {
			"code": code
		};
		newAjaxPost("/h5/prescriptionOrder/getH5OpenId", paramJson, getOpenIdOK);
		// sessionStorage.setItem("code", code);
	}

	function getOpenIdOK(rstData) {
		if (rstData.code == 1) {
			wxcode = rstData.data
		}
	}
	//获取地址栏的参数
	function getUrlParam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var r = window.location.search.substr(1).match(reg);
		if (r != null) return unescape(r[2]);
		return null;
	}
</script>